# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.


class ApplicationController < ActionController::Base
  include AuthenticatedSystem
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_cdocs_session_id'
  
  def rescue_action_in_public(exception)
    case exception
    when
      ::ActiveRecord::RecordNotFound,
      ::ActionController::UnknownController,
      ::ActionController::UnknownAction,
      ::ActionController::RoutingError
      logger.error("access to nonexistent object #{params[:id]} in #{controller_name}/#{action_name} ")
      render_404
      
    else
      render_500
    end
  end
  
  def render_404
    respond_to do |format|
      format.html { render :file => "#{RAILS_ROOT}/public/404.html", :status => '404 Not Found' }
      format.xml  { render :nothing => true, :status => '404 Not Found' }
    end
    true
  end
end
